#include <linux/refcount.h>
#include <linux/printk.h>

#include <msh/export.h>

static int reftest(void)
{
    refcount_t ref = REFCOUNT_INIT(0);
    bool ret;

    ret = refcount_dec_and_test(&ref);
    printk("refcount_dec_and_test(%d): %d\n", ref.refs.counter, ret);

    refcount_set(&ref, 1);
    ret = refcount_dec_and_test(&ref);
    printk("refcount_dec_and_test(%d): %d\n", ref.refs.counter, ret);

    refcount_set(&ref, 2);
    ret = refcount_dec_and_test(&ref);
    printk("refcount_dec_and_test(%d): %d\n", ref.refs.counter, ret);

    return 0;
}
MSH_CMD_EXPORT(reftest, refcount test);
